/*
 * main.cpp
 *
 *  Created on: 03.02.2013
 *      Author: Maksim Lazeba
 */

#include "region_search.h"
#include <iostream>

int main()
{
	int n;
	std::cin >> n;

	std::vector<point_t> points;
	double x, y;

	for (int i = 0; i < n; i++)
	{
		std::cin >> x >> y;
		points.push_back(point_t(x, y));
	}

	region_tree tree(points);

	int m;
	std::cin >> m;

	double ax, ay, bx, by;
	for (int i = 0; i < m; i++)
	{
		std::cin >> ax >> ay;
		std::cin >> bx >> by;
		point_t a(ax, ay);
		point_t b(bx, by);
		std::vector<point_t> ans = tree.get_points_in_rect(rect_t(a, b));

		std::cout << ans.size() << "\n";
		std::cout.precision(30);
		for (auto i = ans.begin(); i < ans.end(); i++)
		{
			std::cout << (*i).x << " " << (*i).y << "\n";
		}
	}
}

